use std::fmt::{self, Display, Formatter};

#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CardInfo {
    pub val: u8,
    pub color: u8,
    pub name: String,
}

impl CardInfo {
    pub fn new(val: u8, color: u8) -> CardInfo {
        let name = match val {
            0 => "小王".to_string(),
            1 => "大王".to_string(),
            2..=10 => format!("{}", val),
            11 => "J".to_string(),
            12 => "Q".to_string(),
            13 => "K".to_string(),
            14 => "A".to_string(),
            _ => "".to_string(),
        };
        CardInfo { val, color, name }
    }
}

impl Display for CardInfo {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        write!(f, "{}{}", match self.color {
            1 => "♠",
            2 => "♥",
            3 => "♣",
            4 => "♦",
            _ => "",
        },self.name)
    }
}


#[warn(dead_code)]
pub struct DdzCard {
    pub cards: Vec<CardInfo>,
}

pub const CARD_NUM: usize = 54;